package agency.tango.materialintroscreen;

import agency.tango.materialintroscreen.utils.LogUtil;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;

import agency.tango.materialintroscreen.slice.MaterialIntroSlice;
import ohos.aafwk.content.Operation;
import ohos.event.commonevent.CommonEventData;
import ohos.event.commonevent.CommonEventManager;
import ohos.rpc.RemoteException;

/**
 * @ProjectName: material-intro-screen-master
 * @Package: agency.tango.materialintroscreen
 * @ClassName: MaterialIntroAbility
 * @Description: pageslider介绍页
 * @CreateDate: 2021/4/12 20:03
 * @UpdateDate: 2021/4/12 20:03
 * @UpdateRemark: 暂无
 * @Version: 1.0
 */
public abstract class MaterialIntroAbility extends Ability {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setMainRoute(MaterialIntroSlice.class.getName());
    }

    @Override
    public void onRequestPermissionsFromUserResult(int requestCode, String[] permissions, int[] grantResults) {
        try {
            Intent intent = new Intent();
            Operation operation = new Intent.OperationBuilder()
                    .withAction(Constants.PERMISSION_ACTION)
                    .build();
            intent.setOperation(operation);
            intent.setParam(Constants.REQUEST_PERMISSION_CODE, requestCode);
            intent.setParam(Constants.PERMISSION_RESULT, permissions);
            intent.setParam(Constants.GRANT_RESULT, grantResults);
            CommonEventData eventData = new CommonEventData(intent);
            CommonEventManager.publishCommonEvent(eventData);
        } catch (RemoteException e) {
            LogUtil.error("MaterialIntroAbility ", e.toString());
        }
    }
}
